#ifndef GENERIC_RESULT_CODES_H
#define GENERIC_RESULT_CODES_H

namespace base{

//namespace base is assigned project number 0
//error codes will begin with 0x8...
//non-error codes will begin with 0x0...
const int kProjectId       = 0x00000000;

enum Success {
	OK_OK                 = 0x00000000,
	OK_TRUE               = 0x00000001,
	OK_FALSE              = 0x00000002
};

enum Error{
	ER_ERROR              = 0x80000000,
	ER_NULL_POINTER       = 0x80000001,
	ER_FAIL_TO_READ_FILE  = 0x80000002,
	ER_TEMPLATING         = 0x80000004,
	ER_UNREACHABLE_CODE   = 0x80000008,
	ER_FILE_FORMAT        = 0x80000010,
};

} //namespace base

namespace result_code {

//Extract the Project Id from the result_code
inline int  SourceId(const int & result_code)		{return result_code & 0x70000000;}

//Extract the bias from the result_code
inline int  Bias(const int & result_code)           {return result_code & 0x80000000;}

//Extract Bias and Project Id from the result_code
inline int	BiasAndSource(const int & result_code)	{return result_code & 0xF0000000;}
 

//Test if the result_code is an error
inline bool IsError(const int & result_code)	{return result_code < 0;}


//Test if the result_code is a success
inline bool IsSuccess(const int & result_code)	{return result_code >= 0;}

//Test result code equality
inline bool Equals(const int & result_code, const int & expected_code) {
	return (result_code == expected_code);
}

//Test result code inequality
inline bool NotEquals(const int & result_code, const int & expected_code) {
	return (result_code != expected_code);
}

//Test that result_code contains the code expected_code
inline bool Includes(const int & result_code, const int & expected_code) {
    return (result_code & expected_code) == expected_code;
}

//Test that result_code doest not contains the code expected_code
inline bool NotIncludes(const int & result_code, const int & expected_code) {
    return (result_code & expected_code) != expected_code;
}
 
}
#endif //GENERIC_RESULT_CODES_H